<template>
  <div>
    <!-- 面包屑 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item>信息流管理</el-breadcrumb-item>
      <el-breadcrumb-item>
        <span
          class="u-cursor"
          @click="$router.back()"
        >产品管理</span>
      </el-breadcrumb-item>
      <el-breadcrumb-item>产品状态详情</el-breadcrumb-item>
    </el-breadcrumb>

    <Container>
      <ContainerTitle>{{pageTitle}}</ContainerTitle>
      <!-- 表格 -->
      <el-table
        border
        stripe
        :data="tableData"
      >
        <el-table-column
          align="center"
          v-for="(item, index) in tableColumn"
          :label="item.label"
          :key="index"
        >
          <template slot-scope="scope">
            <!-- 其他 -->
            <div class="u-prewrap">{{scope.row[item.prop]}}</div>
          </template>
        </el-table-column>
      </el-table>
      <el-row
        type="flex"
        justify="space-between"
      >
        <div class="u-mt15">
          <el-button
            size="small"
            @click="$router.back()"
          >返回</el-button>
        </div>
        <!-- 分页 -->
        <el-col>
          <el-pagination
            background
            :page-sizes="[50, 100, 500, 1000]"
            :page-size="page.pageSize"
            layout="total, prev, pager, next, sizes"
            :total="pageTotal"
            @size-change="handlePagerSizeChange"
            @current-change="handlePagerCurrentChange"
          />
        </el-col>
      </el-row>
    </Container>
  </div>
</template>

<script>
import Container from "@/components/container";
import ContainerTitle from "@/components/container-title";

export default {
  components: {
    Container,
    ContainerTitle
  },
  data() {
    return {
      pageTitle: this.$route.query.title,

      filter: {
        productId: this.$route.query.id
      },

      tableData: [],
      tableColumn: [
        {
          label: "操作记录",
          prop: "operationRecords"
        },
        {
          label: "操作人",
          prop: "updateBy"
        },
        {
          label: "操作时间",
          prop: "updateTime"
        }
      ],
      page: {
        pageNo: 1,
        pageSize: 50
      },
      pageTotal: 0
    };
  },
  methods: {
    getTable() {
      this.$http({
        method: "post",
        url: "/manage/api/bus/product/get_service_rate_details",
        data: {
          ...this.page,
          ...this.filter
        }
      }).then(res => {
        if (res.data.code === 0) {
          let data = res.data.data;
          this.tableData = data.list;
          this.pageTotal = data.listCount;
        } else {
          this.$message.error(res.data.msg);
        }
      });
    },
    handlePagerSizeChange(v) {
      this.page.pageSize = v;
      this.getTable();
    },
    handlePagerCurrentChange(v) {
      this.page.pageNo = v;
      this.getTable();
    }
  },
  created() {
    this.getTable();
  }
};
</script>